/**
 * 安卓白金英雄坛制作组 <br>
 * 文件名：Tileset.java <br>
 * 创建时间：2013-5-20 下午4:16:12 <br>
 * 所属项目：GmudEX <br>
 * @author 12548 <br>
 */
package lostland.gmud.exv2;

import android.graphics.Canvas;

import lostland.gmud.exv2.blgframework.impl.BLGGraphics;
import lostland.gmud.exv2.blgframework.impl.BLGPixmap;

/**
 * 类名：Tileset <br>
 * 说明：设置贴图
 *
 * @author 12548
 */
public abstract class Tileset {
	BLGPixmap pixmap;
	int tileWidth;
	int tileHeight;

	/**
	 * @param pixmap
	 * @param tileWidth
	 * @param tileHeight
	 */
	public Tileset(BLGPixmap pixmap, int tileWidth, int tileHeight) {
		this.pixmap = pixmap;
		this.tileWidth = tileWidth;
		this.tileHeight = tileHeight;
	}

	/**
	 * @return pixmap
	 */
	public BLGPixmap getPixmap() {
		return pixmap;
	}

	/**
	 * @return tileWidth
	 */
	public int getTileWidth() {
		return tileWidth;
	}

	/**
	 * @return tileHeight
	 */
	public int getTileHeight() {
		return tileHeight;
	}

	/**
	 * 注意：srcX和srcY为要画的tile块在tileset中的坐标（从0开始）。
	 */
	public void drawInMap(BLGGraphics g, int x, int y, int srcX, int srcY) {
		g.drawPixmapInMap(pixmap, x, y, srcX * tileWidth, srcY * tileHeight, tileWidth + 1, tileHeight + 1);
	}

	public void drawInCanvas(BLGGraphics g, int x, int y, int srcX, int srcY, Canvas ca) {
		g.drawPixmapInCanvas(pixmap, x, y, srcX * tileWidth, srcY * tileHeight, tileWidth + 1, tileHeight + 1, ca);
	}

	/**
	 * 注意：srcX和srcY为要画的tile块在tileset中的坐标（从0开始）。
	 */
	public void draw(BLGGraphics g, int x, int y, int srcX, int srcY) {
		g.drawPixmap(pixmap, x, y, srcX * tileWidth, srcY * tileHeight, tileWidth + 1, tileHeight + 1);
	}
}
